<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>商户后台登录</title>
	<link rel="shortcut icon" href="__PUBLIC__/admin/favicon.ico">
	<link href="__PUBLIC__/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
	<link rel="stylesheet" href="__PUBLIC__/admin/css/admin_login.css">
</head>
<style>
	.form-control{
		border-radius:0;
	}
	.form-input{
		height: 2.5rem;
	}
</style>
<body>
<div class="layout">
	<div class="main-cont" style="width: 20%;margin-bottom: 7rem">
		<div class="main-tit">商户后台管理</div>
		<div class="form-group">
			<span class="label-tit">账号</span>
			<input type="text" autocomplete="new-password" value="<?= $_COOKIE['xyc_account'];?>" name="" id="account" class="form-input">
		</div>
		<div class="form-group">
			<span class="label-tit">密码</span>
			<input type="password"autocomplete="new-password" id="pwd" value="<?= $_COOKIE['xyc_pwd'];?>" class="form-input">
		</div>

		<div style="display: none" id="display">
			<span class="label-tit">验证码</span>
			<div class="form-group">
				<input type="text" autocomplete="off" id="img_verify"  class="form-control"  placeholder="验证码" required="" style="width:40%;float:left;height: 2.5rem" >
				<img id="verifyImg" src="__MODULE__/Login/mk_verify" onclick="this.src='__MODULE__/Login/mk_verify/s/'+Math.random()" style="width:60%;height: 2.5rem;border-radius:3px;margin-top: 0.5px" />
			</div>
			<div class="form-group">
				<input type="number" id="verify" autocomplete="off" class="form-control"  placeholder="验证码" required="" style="width:66%;float:left" ><a class="btn btn-success" href="javascript:void(0);"  onclick="send_verify()" id="num" style="width:33%;padding: 6px 12px;"  >发送验证码</a>
			</div>
		</div>



		<div class="form-remember">
			<label>
				<input type="checkbox"  <?php if($_COOKIE['xyc_save']=='2'){echo 'checked';}?> class="save" id="save" >
				<i class="icon-check"></i>
				<span><label for="save">记住我</label></span>

			</label>

			<a href="javascript:void(0)" onclick="forget_pwd()" style="float: right;cursor:pointer">忘记密码</a>
		</div>
		<div class="form-login">
			<div class="loginbtn" id="login_btn">登录</div>
		</div>
	</div>
	<div class="footer-copyright">
		<span>Copyright &copy; 2018 鼎信普惠信息服务有限公司</span>
	</div>
</div>
</body>
<script src="__PUBLIC__/admin/js/jquery.min.js?v=2.1.4"></script>
<script src="__PUBLIC__/admin/js/bootstrap.min.js?v=3.3.6"></script>

<script src="__PUBLIC__/admin/js/plugins/layer/layer.min.js"></script>
<script>

	$('#login_btn').on('click', function(){
		var account=$('#account').val();
		var pwd=$('#pwd').val();
		var verify=$('#verify').val()==''?'':$('#verify').val();
		var tourl="__MODULE__/Index/index";
		var save=document.getElementById("save").checked===true?2:1
		layer.load(2);
		$.post('__MODULE__/Login/get_login',{account:account,pwd:pwd,verify:verify,save:save},function(data){
			layer.closeAll();
			if(data.code=='1001'){
				window.location.href=tourl;
			}else if(data.code=='1002'){
				layer.msg(data.result,{time:2000,icon:5});
			}else{
				$('#display').show();
				layer.msg(data.result,{time:2000,icon:5});
			}
		});
	})
	function send_verify(){
		var account=$('#account').val();
		var img_verify=$('#img_verify').val();
		layer.load(2);
		$.post('__MODULE__/Login/send_verify',{account:account,img_verify:img_verify},function(data){
			layer.closeAll();
			if(data.code=='1001'){
				layer.msg(data.result,{time:1000,icon:6});
				$('#num').attr('onclick',null);
				$('#num').html('180');
				s=setInterval('set_time()',1000);
			}else{
				$('#verifyImg').attr('src','__MODULE__/Login/mk_verify/s/'+Math.random());
				$('#img_verify').val('');
				layer.msg(data.result,{time:1000,icon:5});
			}
		});

	}
	var num=179;
	function set_time(){
		if(num>0){
			$('#num').html(num);
			num=num-1;
		}else{
			num=179;
			clearInterval(s);
			$('#num').html('发送验证码');
			$('#num').attr('onclick','send_verify()');
		}
	}
	document.onkeydown=function(event){
		var e = event || window.event || arguments.callee.caller.arguments[0];
		if(e && e.keyCode==27){ // 按 Esc
			//要做的事情
		}
		if(e && e.keyCode==113){ // 按 F2
			//要做的事情
		}
		if(e && e.keyCode==13){ // enter 键
			$('#login_btn').click();
			//要做的事情
		}
	};

	//修改密码
	function forget_pwd() {
		url='__MODULE__/Login/forget_pwd';
		layer.open({
			type: 2,
			title: '忘记密码',
			shadeClose: true,
			shade: false,
			maxmin: true, //开启最大化最小化按钮
			area: ['40%','60%'],
			content: url
		});
	}


</script>
</html>